#comments-start - More Info Dialog
[SCRIPT NAME]Launch
Description:
    - Launches the specified application, folder, or file which would open in the default program.

Arguments:
    - Arg1: Path to the file, folder, or program you want to launch. (Required) - e.g. TaskMgr, C:\MyFile.txt, C:\MyApp.exe, or C:\MyFilesFolder
    - Arg2: Parameters to pass to the executing program [Optional]
    - Arg3: The working directory. Blank ("") uses the current working directory. [Optional]
    - Arg4: The verb to pass in. [Optional]
        - Options: (See AutoIt help for more options and info)
            - open = Opens the file specified. The file can be an executable file, a document file, or a folder (Default)
            - edit = Launches an editor and opens the document for editing. If "filename" is not a document file, the function will fail
            - print = Prints the document file specified. If "filename" is not a document file, the function will fail
            - properties = Displays the file or folder's properties
    - Arg5: ShowFlag [Optional]
        - Options:
            - "" = Not Used (Default)
            - Hide = Hidden window
            - Minimize = Minimized window
            - Maximize = Maximized window
        - The application determines how these values are handled. Some will ignore and some may do things you don't expect.
    - Arg6: Wait for program to exit [Optional]
        - Options:
            - True
            - False (Default)
#comments-end - More Info Dialog
#include <Include\WinClickPro.au3>

Func Main()
	Local $sFileName = ""
	Local $sParameters = ""
	Local $sWorkingDirectory = "";
	Local $sVerbs = "open" ; Default
	Local $sShowFlag = -1 ; Default is invalid value and will be replaced with @Macro or ignored.
	Local $sWaitForExit = "false" ; Default

	;
	; This script has 1 required argument and 5 optional.
	;
	If $CmdLine[0] < 1 Then
		_DisplayErrorAndExit("Invalid argument count detected!" & @LF & "Count: " & $CmdLine[0])
	EndIf

	$sFileName = $CmdLine[1]

	If $CmdLine[0] > 1 Then
		$sParameters = $CmdLine[2]
	EndIf

	If $CmdLine[0] > 2 Then
		$sWorkingDirectory = $CmdLine[3]
	EndIf

	If $CmdLine[0] > 3 Then
		$sVerbs = StringLower($CmdLine[4])
		;
		; Handle user passing in blank value
		;
		If $sVerbs = "" Then
			$sVerbs = "open"
		EndIf
	EndIf

	If $CmdLine[0] > 4 Then
		Switch(StringLower($CmdLine[5]))
			Case ""
				$sShowFlag = -1 ; Invalid value will be ignored
			Case "hide"
				$sShowFlag = @SW_HIDE
			Case "minimize"
				$sShowFlag = @SW_MINIMIZE
			Case "maximize"
				$sShowFlag = @SW_MAXIMIZE
			Case Else
				_DisplayErrorAndExit("Invalid ShowFlag specifed!" & @LF & "Value: " & $CmdLine[5])
		EndSwitch
	EndIf

	If $CmdLine[0] > 5 Then
		$sWaitForExit = StringLower($CmdLine[6]);
		;
		; Handle user passing in blank value
		;
		If $sWaitForExit = "" Then
			$sWaitForExit = "false"
		ElseIf $sWaitForExit <> "true" And $sWaitForExit <> "false" Then
			_DisplayErrorAndExit("Invalid value specified for ""Wait for program to exit.""" & @LF & " Value: " & $sWaitForExit)
		EndIf
	EndIf

	If $sWaitForExit == "false" Then
		If $sShowFlag <> -1 Then
			ShellExecute($sFileName, $sParameters, $sWorkingDirectory, $sVerbs, $sShowFlag)
		Else
			ShellExecute($sFileName, $sParameters, $sWorkingDirectory, $sVerbs)
		EndIf
	Else
		If $sShowFlag <> "" Then
			ShellExecuteWait($sFileName, $sParameters, $sWorkingDirectory, $sVerbs, $sShowFlag)
		Else
			ShellExecuteWait($sFileName, $sParameters, $sWorkingDirectory, $sVerbs)
		EndIf
	EndIf
EndFunc

Main()
Exit @error